// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-12

package post

import (
	"gitee.com/go-libs/db-xorm/db"
	"server/app/kind"
)

// Request
// 入参.
type Request struct {
	Id int `label:"渔票ID" desc:"允许编辑"`

	Mode      kind.TicketMode `validate:"required,min=1" label:"模式位码"`
	ModeStart db.Date         `validate:"required" label:"开始日期"`
	ModeEnd   db.Date         `validate:"required" label:"截至日期"`

	Time      kind.TicketTime `validate:"required,min=1" label:"作钓时段"`
	TimeStart string          `validate:"required" label:"开始时间"`
	TimeEnd   string          `validate:"required" label:"结束时间"`

	PondId int64 `validate:"required,min=1" label:"鱼塘ID"`

	Seat         kind.PondSeat           `validate:"required,min=1" label:"钓位类型"`
	SeatStrategy kind.TicketSeatStrategy `label:"钓位策略"`

	Hours float64      `validate:"required,min=0.5,max=24" label:"作钓时长"`
	Price kind.Balance `validate:"required,min=1,max=9999" label:"渔票票价"`

	Quantity int    `validate:"min=0,max=300" label:"最大人数"`
	Name     string `validate:"required,min=2,max=30" label:"渔票标题"`
}

// BeforeValidate
// 前置校验.
func (o *Request) BeforeValidate() error {
	// 1. 单场模式.
	//    此模式下结束日期与开始日期一致.
	if o.Mode.IsSingle() {
		o.ModeEnd = o.ModeStart
	}

	return nil
}
